<?php

require_once 'Pipes/Decorator.php';
require_once 'Pipes/Xml/NodeList.php';
require_once 'PipesImpl/Visitable.php';

abstract class Pipes_Xml_Node
	extends Pipes_Decorator
	implements PipesImpl_Visitable
{
	public function __get($key) {
		if ($key == 'childNodes') {
			return new Pipes_Xml_NodeList($this->domNode()->$key);
		}
		
		return parent::__get($key);
	}
	
	public function domNode() {
		return $this->_decorated;
	}
	
	public function getElementsByTagName($tagName) {
		return new Pipes_Xml_NodeList(
			$this->domNode()->getElementsByTagName($tagName)
		);
	}
	
	public function accept(PipesImpl_Visitor $visitor) {
		return $visitor->visit($this);
	}
}
